package com.example.personal.aiagent.xunfei.account.model.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.personal.aiagent.xunfei.account.model.entity.AccountEntity;
import com.example.personal.aiagent.xunfei.account.model.vo.AccountRequest;
import com.example.personal.aiagent.xunfei.account.model.vo.AccountResponse;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

/**
 * 账户
 */
@Data
@ToString(exclude = { "apiSecret", "apiKey" })
@AllArgsConstructor
@NoArgsConstructor
public class AccountDTO {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private Integer userId;

    private String appId;

    private String apiSecret;

    private String apiKey;

    private String createTimeDisplay;

    private String modifyTimeDisplay;

    private Integer createTimestamp;

    private Integer modifyTimestamp;

    public static AccountDTO entityToDTO(AccountEntity entity) {
        if (entity == null) {
            return null;
        }
        AccountDTO res = new AccountDTO();
        BeanUtils.copyProperties(entity, res);
        return res;
    }

    public static AccountEntity dTOToEntity(AccountDTO dto) {
        if (dto == null) {
            return null;
        }
        AccountEntity entity = new AccountEntity();
        BeanUtils.copyProperties(dto, entity);
        return entity;
    }

    public static AccountDTO voToDTO(AccountRequest request) {
        if (request == null) {
            return null;
        }
        AccountDTO res = new AccountDTO();
        BeanUtils.copyProperties(request, res);
        return res;
    }

    public static AccountResponse dTOToVo(AccountDTO dto) {
        if (dto == null) {
            return null;
        }
        AccountResponse res = new AccountResponse();
        BeanUtils.copyProperties(dto, res);
        return res;
    }
}
